import React from "react";
import PropTypes from "prop-types";
import QRCode from 'qrcode.react';

class AppErwei extends React.Component {
    constructor(props, context) {
        super(props, context);
        this.sceneId = this.props.location.state.sceneId;
        this.openInstllUrl="http://oss0.boyueguoxue.cn/apks/oiInstall.html?oiChannelId=";
        this.openInstlEndUrl="&oiSubChannelId=0&oiUid=0&oiEnv=0&oiParam1=0&oiParam2=0&channelCode=";
        this.state={qSize : 180}

    }

    componentWillMount(){
        const clienWidth = document.documentElement.clientWidth;
        this.state.qSize = Math.floor(this.state.qSize*clienWidth/320);
        console.log("01_"+document.documentElement.clientWidth);
        console.log("02_"+ this.state.qSize);
    }

    render() {

        return (
                <QRCode
                    value={this.openInstllUrl+this.sceneId+this.openInstlEndUrl+this.sceneId}
                    size={this.state.qSize}
                    fgColor= '#000000'
                    bgColor='#ffffff'
                    level= 'L'
                    renderAs= 'Canvas'
                />
        )
    }
}

AppErwei.contextTypes = {
    router: PropTypes.object.isRequired
};

export default AppErwei;